function(ADD_TOOL TOOL_NAME SRC_FILE)
    add_executable(${TOOL_NAME} ${SRC_FILE})
    target_link_libraries(${TOOL_NAME} app)
    install(TARGETS ${TOOL_NAME} DESTINATION bin)
endfunction()

add_library(app app.cpp)
target_link_libraries(app pisa CLI11)

add_tool(compress_inverted_index compress_inverted_index.cpp)
add_tool(create_wand_data create_wand_data.cpp)
add_tool(queries queries.cpp)
add_tool(evaluate_queries evaluate_queries.cpp)
add_tool(thresholds thresholds.cpp)
add_tool(profile_queries profile_queries.cpp)
add_tool(evaluate_collection_ordering evaluate_collection_ordering.cpp)
add_tool(parse_collection parse_collection.cpp)
add_tool(invert invert.cpp)
add_tool(read_collection read_collection.cpp)
add_tool(partition_fwd_index partition_fwd_index.cpp)
add_tool(compute_intersection compute_intersection.cpp)
add_tool(lexicon lexicon.cpp)
add_tool(extract_topics extract_topics.cpp)
add_tool(sample_inverted_index sample_inverted_index.cpp)
add_tool(map_queries map_queries.cpp)
add_tool(stem_queries stem_queries.cpp)
add_tool(count-postings count_postings.cpp)
add_tool(selective_queries selective_queries.cpp)
add_tool(shards shards.cpp)
add_tool(reorder-docids reorder_docids.cpp)
add_tool(kth_threshold kth_threshold.cpp)
add_tool(taily-stats taily_stats.cpp)
add_tool(taily-thresholds taily_thresholds.cpp)
add_tool(extract-maxscores extract_maxscores.cpp)
add_tool(lookup-table lookup_table.cpp)

configure_file(../script/ir-datasets.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ir-datasets COPYONLY)

if (PISA_ENABLE_TESTING AND BUILD_TESTING)
    add_subdirectory(tests)
endif()
